package com.cloudsigns.factorymanager2.engineering.customview;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.engineering.adapter.BatchInstallOrderProductInfoAdapter;
import com.cloudsigns.factorymanager2.project.bean.ProductBean;
import com.cloudsigns.factorymanager2.project.customview.TitleDialog;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;
import com.cloudsigns.factorymanager2.project.utils.DpUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tony on 2018/1/25.
 */

public class ReadDilalog extends Dialog {


    private Context mContext;
    private View dialogView;

    public ReadDilalog(Context context) {
        super(context, R.style.TitleDialogTheme);
        this.mContext = context;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(dialogView);
    }

    /**
     * 项目信息对话框
     */
    public void createProjectInfoDialog() {
        dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_projectinfo_batch_engineering, null);

        initProjectHolder();

        WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
        localLayoutParams.x = 0;
//        int y = DpUtil.dip2px(mContext, 40);
        localLayoutParams.y = 0;
        localLayoutParams.gravity = Gravity.CENTER;
//        dialogView.setMinimumWidth(10000);

        onWindowAttributesChanged(localLayoutParams);
        setCanceledOnTouchOutside(true);
        setCancelable(true);

    }

    /**
     * 工程信息对话框
     */
    public void createEngineeringInfoDialog(String engineeringName, List<ProductBean> datas) {
        dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_engineeringinfo_batch_install, null);

        List<ProductBean> dataLs = new ArrayList<>();
//        dataLs.add(new ProductBean("", 0, "", "", 0, null));
//        dataLs.add(new ProductBean("", 0, "", "", 0, null));
//        dataLs.add(new ProductBean("", 0, "", "", 0, null));
//        dataLs.add(new ProductBean("", 0, "", "", 0, null));


        initEngineeringInfoHolder("科研路餐厅", dataLs);
        WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
        localLayoutParams.x = 0;
        localLayoutParams.y = 0;
        localLayoutParams.gravity = Gravity.CENTER;


        onWindowAttributesChanged(localLayoutParams);
        setCanceledOnTouchOutside(true);
        setCancelable(true);

    }

    /**
     * 施工工程信息对话框
     */
    public void createConstructEngineeringDialog() {
        dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_engineeringinfo_receive_construct, null);

        WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
        localLayoutParams.x = 0;
//        int y = DpUtil.dip2px(mContext, 40);
        localLayoutParams.y = 0;
        localLayoutParams.gravity = Gravity.CENTER;
//        dialogView.setMinimumWidth(10000);

        onWindowAttributesChanged(localLayoutParams);
        setCanceledOnTouchOutside(true);
        setCancelable(true);

    }

    private void initProjectHolder() {

        final ProjectHolder holder = new ProjectHolder();
        holder.edt_dispath_order_company = dialogView.findViewById(R.id.edt_dispath_order_company);
        holder.edt_dispath_order_person_colon = dialogView.findViewById(R.id.edt_dispath_order_person_colon);
        holder.edt_dispath_order_time_colon = dialogView.findViewById(R.id.edt_dispath_order_time_colon);
        holder.edt_completion_date = dialogView.findViewById(R.id.edt_completion_date);
        holder.edt_receive_people_colon = dialogView.findViewById(R.id.edt_receive_people_colon);
        holder.edt_reception_time_colon = dialogView.findViewById(R.id.edt_reception_time_colon);

    }

    private void initEngineeringInfoHolder(String title, List<ProductBean> datas) {
        final EngineeringInfoHolder holder = new EngineeringInfoHolder();
        holder.tv_engineering_name = dialogView.findViewById(R.id.tv_engineering_name);
        holder.lv = dialogView.findViewById(R.id.lv);


        holder.tv_engineering_name.setText(title);
        BatchInstallOrderProductInfoAdapter adapter = new BatchInstallOrderProductInfoAdapter(mContext, "");
        adapter.setData(datas);
        holder.lv.setAdapter(adapter);

    }


    class ProjectHolder {
        TextView edt_dispath_order_company;
        TextView edt_dispath_order_person_colon;
        TextView edt_dispath_order_time_colon;
        TextView edt_completion_date;
        TextView edt_receive_people_colon;
        TextView edt_reception_time_colon;
    }

    class EngineeringInfoHolder {
        TextView tv_engineering_name;
        ListView lv;
    }


}
